package com.gobrs.async.core.threadpool;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Objects;

public abstract class GobrsThreadPoolConfiguration implements InitializingBean  {

    @Autowired(required = false)
    private GobrsAsyncThreadPoolFactory gobrsAsyncThreadPoolFactory;

    public void initialize(GobrsAsyncThreadPoolFactory factory) {
        doInitialize(factory);
    }

    protected abstract void doInitialize(GobrsAsyncThreadPoolFactory factory);

    @Override
    public void afterPropertiesSet() throws Exception {
        if (Objects.nonNull(gobrsAsyncThreadPoolFactory)) {
            initialize(gobrsAsyncThreadPoolFactory);
        }
    }

}
